<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>移动端底部导航栏</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            min-height: 100vh;
            background: #f8f8f8;
        }

        .navigation {
            position: fixed;
            bottom: 0;
            width: 100%;
            height: 70px;
            background: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 10px 10px 0 0;
        }

        .navigation ul {
            display: flex;
            width: 350px;
        }

        .navigation ul li {
            position: relative;
            list-style: none;
            width: 70px;
            height: 70px;
            z-index: 2;
        }

        .navigation ul li a {
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            width: 100%;
            text-align: center;
            font-weight: 500;
            color: #333;
            text-decoration: none;
        }

        .navigation ul li a .icon {
            position: relative;
            display: block;
            line-height: 75px;
            color: #333;
        }

        .navigation ul li a .icon svg {
            width: 24px;
            height: 24px;
            stroke: #333;
            stroke-width: 1;
            fill: none;
            opacity: 1;
            transition: opacity 0.3s ease;
        }

        .navigation ul li.active a .icon svg {
            opacity: 0;
        }

        .navigation ul li a .text {
            position: absolute;
            font-size: 0.75em;
            color: #333;
            font-weight: 400;
            letter-spacing: 0.05em;
            transition: 0.5s;
            opacity: 0;
            transform: translateY(20px);
        }

        .navigation ul li.active a .text {
            opacity: 1;
            transform: translateY(10px);
        }

        .indicator {
            position: absolute;
            top: -35px;
            width: 70px;
            height: 70px;
            background: #2196f3;
            border-radius: 50%;
            border: 6px solid #f8f8f8;
            transition: 0.5s;
            z-index: 1;
        }

        .indicator::before {
            content: '';
            position: absolute;
            top: 50%;
            left: -22px;
            width: 20px;
            height: 20px;
            background: transparent;
            border-top-right-radius: 20px;
            box-shadow: 1px -10px 0 0 #f8f8f8;
        }

        .indicator::after {
            content: '';
            position: absolute;
            top: 50%;
            right: -22px;
            width: 20px;
            height: 20px;
            background: transparent;
            border-top-left-radius: 20px;
            box-shadow: -1px -10px 0 0 #f8f8f8;
        }

        .indicator svg {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 24px;
            height: 24px;
            stroke: #fff;
            stroke-width: 2;
            fill: none;
            transition: all 0.3s ease;
            opacity: 1;
        }

        .indicator svg path,
        .indicator svg circle,
        .indicator svg polyline {
            stroke-dasharray: 100;
            stroke-dashoffset: 100;
            transition: stroke-dashoffset .8s ease;
        }

        .indicator svg.animate path,
        .indicator svg.animate circle,
        .indicator svg.animate polyline {
            stroke-dashoffset: 0;
        }

        .navigation ul li:nth-child(1).active~.indicator {
            transform: translateX(calc(70px * 0));
        }

        .navigation ul li:nth-child(2).active~.indicator {
            transform: translateX(calc(70px * 1));
        }

        .navigation ul li:nth-child(3).active~.indicator {
            transform: translateX(calc(70px * 2));
        }

        .navigation ul li:nth-child(4).active~.indicator {
            transform: translateX(calc(70px * 3));
        }

        .navigation ul li:nth-child(5).active~.indicator {
            transform: translateX(calc(70px * 4));
        }

        .navigation ul li.active a .text {
            color: #2196f3;
        }
    </style>
</head>

<body>
    <div class="navigation">
        <ul>
            <li class="active">
                <a href="javascript:void(0);">
                    <span class="icon">
                        <svg viewBox="0 0 24 24">
                            <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
                            <polyline points="9 22 9 12 15 12 15 22"></polyline>
                        </svg>
                    </span>
                    <span class="text">首页</span>
                </a>
            </li>
            <li>
                <a href="javascript:void(0);">
                    <span class="icon">
                        <svg viewBox="0 0 24 24">
                            <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
                            <circle cx="12" cy="7" r="4"></circle>
                        </svg>
                    </span>
                    <span class="text">个人</span>
                </a>
            </li>
            <li>
                <a href="javascript:void(0);">
                    <span class="icon">
                        <svg viewBox="0 0 24 24">
                            <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
                        </svg>
                    </span>
                    <span class="text">消息</span>
                </a>
            </li>
            <li>
                <a href="javascript:void(0);">
                    <span class="icon">
                        <svg viewBox="0 0 24 24">
                            <path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z">
                            </path>
                            <circle cx="12" cy="13" r="4"></circle>
                        </svg>
                    </span>
                    <span class="text">照片</span>
                </a>
            </li>
            <li>
                <a href="javascript:void(0);">
                    <span class="icon">
                        <svg viewBox="0 0 24 24">
                            <circle cx="12" cy="12" r="3"></circle>
                            <path
                                d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z">
                            </path>
                        </svg>
                    </span>
                    <span class="text">设置</span>
                </a>
            </li>
            <div class="indicator"></div>
        </ul>
    </div>

    <script>
        const list = document.querySelectorAll('.navigation li');
        const indicator = document.querySelector('.indicator');

        function activeLink() {
            list.forEach((item) => item.classList.remove('active'));
            this.classList.add('active');

            // 添加过渡效果和描边动画
            const oldSvg = indicator.querySelector('svg');
            if (oldSvg) {
                oldSvg.style.opacity = '0';
                setTimeout(() => {
                    const currentSvg = this.querySelector('svg').cloneNode(true);
                    indicator.innerHTML = '';
                    currentSvg.style.opacity = '0';
                    indicator.appendChild(currentSvg);
                    setTimeout(() => {
                        currentSvg.style.opacity = '1';
                        currentSvg.classList.add('animate');
                    }, 50);
                }, 300);
            } else {
                const currentSvg = this.querySelector('svg').cloneNode(true);
                indicator.appendChild(currentSvg);
                currentSvg.classList.add('animate');
            }
        }

        list.forEach((item) => item.addEventListener('click', activeLink));

        // 初始化第一个图标到indicator中
        const firstSvg = list[0].querySelector('svg').cloneNode(true);
        indicator.appendChild(firstSvg);
        firstSvg.classList.add('animate');
    </script>
</body>

</html>